import { _RouteLocationBase } from "vue-router";
import MetaUtil from '@/utils/MetaUtil';

export default class PageCacheUtil {

  private cacheKeySet: Set<string> = new Set();

  public get cacheKeys() {
    return Array.from(this.cacheKeySet);
  }

  public onRouterChange(route: _RouteLocationBase) {
    const cacheKey = MetaUtil.getCacheKey(route);
    if (cacheKey) {
      this.cacheKeySet.add(cacheKey);
    }
  }

  public delete(route: _RouteLocationBase) {
    const cacheKey = MetaUtil.getCacheKey(route);
    if (cacheKey) {
      this.cacheKeySet.delete(cacheKey);
    }
  }

}
